﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using MathematicallySafe.HeadCounter.Data.Common;
using MathematicallySafe.HeadCounter.Data.Models;

namespace MathematicallySafe.HeadCounter.Data.Parsers
{
    public class CharacterXmlParser
    {
        private Raider _raider;

        public void UpdateCharacter(Raider raider, XElement armouryData)
        {
            _raider = raider;

            ParseTalentSpec(armouryData.Element("characterTab").Element("talentSpecs"));
            ParseItems(armouryData.Element("characterTab").Element("items"));
        }

        private void ParseItems(XElement items)
        {
            items.Elements().ForEach(ParseItem);
        }

        private void ParseItem(XElement item)
        {
            var id = Convert.ToInt32(item.Attribute("id").Value);
            _raider.AddGear(id, false);
        }

        private void ParseTalentSpec(XElement talents)
        {
            // Will eventually work out stuff like who is tank, healer, dual wield etc.
        }
    }
}
